//
//  GKZYMajorDetailHeaderView.m
//  GKZYAid
//
//  Created by tony on 16/3/5.
//  Copyright © 2016年 GKZYAid. All rights reserved.
//

#import "GKZYMajorDetailHeaderView.h"
#import "MyDefine.h"
#import "GKZYMajorBoyAndGirlRatioView.h"

@interface GKZYMajorDetailHeaderView ()


@end

@implementation GKZYMajorDetailHeaderView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
    }
    return self;
}

+(GKZYMajorDetailHeaderView *)configureTheHeaderViewWithModel:(GKZYMajorDetailModel *)model andOpneOrPickUp:(BOOL)openOrPickUp{
    
    GKZYMajorDetailHeaderView *view = [[GKZYMajorDetailHeaderView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, KmainScreenBounds.size.width, 40)];
    label.text = @"     专业简介";
    label.layer.borderWidth = 0.5f;
    label.layer.borderColor = [[UIColor colorWithWhite:0.1 alpha:0.1]CGColor];
    [view addSubview:label];
    UILabel *detailInfo = [[UILabel alloc]init];
    detailInfo.numberOfLines = 0;
    detailInfo.lineBreakMode = NSLineBreakByCharWrapping;
    detailInfo.font = [UIFont systemFontOfSize:14];
    detailInfo.text = model.major_intro;
    view.openOrPickButton = [[UIButton alloc]init];
    if (openOrPickUp) {
        CGSize size = [detailInfo sizeThatFits:CGSizeMake(KmainScreenBounds.size.width-40, MAXFLOAT)];
        detailInfo.frame = CGRectMake(20, 30, KmainScreenBounds.size.width-40, size.height);
        view.openOrPickButton.frame = CGRectMake(KmainScreenBounds.size.width*0.3, CGRectGetMaxY(detailInfo.frame)+10, KmainScreenBounds.size.width*0.4, 25);
        [view.openOrPickButton setTitle:@"收起" forState:(UIControlStateNormal)];
    }else{
    
        detailInfo.frame = CGRectMake(20, 30, KmainScreenBounds.size.width -40, 60);
        view.openOrPickButton.frame = CGRectMake(KmainScreenBounds.size.width*0.3, CGRectGetMaxY(detailInfo.frame)+10, KmainScreenBounds.size.width*0.4, 25);
        [view.openOrPickButton setTitle:@"显示全文" forState:(UIControlStateNormal)];
    }
    [view.openOrPickButton setTitleColor:[UIColor orangeColor] forState:(UIControlStateNormal)];
    view.openOrPickButton.layer.cornerRadius = 5;
    view.openOrPickButton.layer.borderWidth = 0.5f;
    view.openOrPickButton.layer.borderColor = [[UIColor orangeColor]CGColor];
    [view addSubview:detailInfo];
    [view addSubview:view.openOrPickButton];
    
    UILabel *label0 = [[UILabel alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(view.openOrPickButton.frame)+15, KmainScreenBounds.size.width, 5)];
    label0.backgroundColor = [UIColor colorWithWhite:0.1 alpha:0.1];
    [view addSubview:label0];
    
    UILabel *label1= [[UILabel alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(view.openOrPickButton.frame)+20, KmainScreenBounds.size.width, 50)];
    label1.layer.borderColor = [[UIColor colorWithWhite:0.1 alpha:0.1]CGColor];
    label1.layer.borderWidth = 0.5f;
    label1.text = @"    男女生的比例";
    [view addSubview:label1];

    GKZYMajorBoyAndGirlRatioView *ratioView = [[GKZYMajorBoyAndGirlRatioView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(label1.frame), KmainScreenBounds.size.width, 120)];
    [ratioView configureTheViewWithGender_info:model.gender_info];
    ratioView.backgroundColor = [UIColor whiteColor];
    [view addSubview:ratioView];
    UILabel *mark = [[UILabel alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(ratioView.frame), KmainScreenBounds.size.width, 5)];
    mark.backgroundColor = [UIColor colorWithWhite:0.1 alpha:0.1];
    [view addSubview:mark];
    
    UILabel *label2 = [[UILabel alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(mark.frame), KmainScreenBounds.size.width+5, 50)];
    label2.text = @"    你可能对以下专业也感兴趣";
    label2.layer.borderWidth = 0.5f;
    label2.layer.borderColor = [[UIColor colorWithWhite:0.1 alpha:0.1]CGColor];
    [view addSubview:label2];
    
    UIView *nameView = [[UIView alloc]initWithFrame:CGRectMake(20, CGRectGetMaxY(label2.frame), KmainScreenBounds.size.width-40, 30)];
    [view addSubview:nameView];
    
    UILabel *label3 = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, KmainScreenBoundsWidth-20, 30)];
    label3.text = @"专业名称";
    label3.backgroundColor = [UIColor clearColor];
    label3.font = [UIFont systemFontOfSize:14];
    label3.textColor = [UIColor colorWithWhite:0.1 alpha:0.5];
    [nameView addSubview:label3];
    
    UILabel *label4 = [[UILabel alloc]initWithFrame:CGRectMake(KmainScreenBoundsWidth/2-15, 0, KmainScreenBoundsWidth/2-40, 30)];
    label4.text = @"类别";
    label4.textColor = [UIColor colorWithWhite:0.1 alpha:0.5];
    label4.textAlignment = NSTextAlignmentRight;
    label4.font = [UIFont systemFontOfSize:14];
    [nameView addSubview:label4];
    view.frame = CGRectMake(0, 0, KmainScreenBounds.size.width, CGRectGetMaxY(nameView.frame));
    
    return view;
}

@end
